
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../../../mobileHeader_inc.jsp" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" /> 
<title>校园新鲜事</title>
<script type="text/javascript">
	var pageArray = [];
	var allCount;//获取总记录条数
	var allPage;//计算出总共页数
	var currentPage = 1;//设置当前页
	var rows = 10;//设置每页列数
	$(document).on('pageinit', function() {
		loadMsg(1);

	});

	function loadMsg(page) {
		currentPage = page;
		$.ajax({
					url : '${ctx}/mobile/getCampus?page=' + page + '&rows='
							+ rows + '',
					dataType : "json",
					async : true,
					success : function(result) {

						//分页相关
						allCount = result.rows;
						allPage = Math.ceil(allCount / rows);//总页数

						var upPage;//上一页
						if (currentPage - 1 <= 0) {
							upPage = 1;
						} else {
							upPage = currentPage - 1;
						}
						var downPage;//下一页
						if (currentPage + 1 > allPage) {
							downPage = allPage;
						} else {
							downPage = currentPage + 1;
						}
						$("#top_count_num").empty();
						$("#count_num").empty();
						var td_need = "  <ul data-am-widget='pagination' class='am-pagination am-pagination-default' >"
								+ " <li class='am-pagination-first'> <a href='#' onclick='loadMsg(1);' target='_self' class=''> 首页</a> </li>"
								+ " <li class='am-pagination-prev'> <a href='#' onclick='loadMsg("
								+ upPage
								+ ");' target='_self' class=''>上页</a> </li>"
								+ "<li class='am-pagination-next'> <a href='#' target='_self' onclick='loadMsg("
								+ downPage
								+ ");' class=''>下页</a> </li>"
								+ "<li class='am-pagination-last'> <a href='#'  target='_self' onclick='loadMsg("
								+ allPage + ");' class=''>末页</a> </li>  </ul>";
						$("#top_count_num").append(td_need);
						//$("#count_num").append(td_need);

						var down_need_num = "  <ul data-am-widget='pagination' class='am-pagination am-pagination-default' > </ul>";
						$("#count_num").append(down_need_num);
						for (var i = 1; i <= allPage; i++) {
							pageArray[i] = i;
							ulNum = "<li class=''><a href='#' class='am-active' onclick='loadMsg("
									+ pageArray[i]
									+ ");' target='_self' >"
									+ pageArray[i] + "</a></li>";
							$("#count_num ul").append(ulNum);
						}

						var $wrapper = $('#doc-scrollspy-wrapper');
						$wrapper.empty();
						var sub_panel;//内容
						var sub_time;//发布时间
						if (result.obj != null) {
							for (var i = 0; i < result.obj.length; i++) {
								sub_time = formatDate(result.obj[i].releaseTime);
								sub_panel = "<a href='/mobile/goNewDetail?id="+result.obj[i].thingId+"' target='_self' class=''><section class='am-panel am-panel-success'> <main class='am-panel-bd'><p><blockquote>"
											+ (i + 1)
											+ "&nbsp;&nbsp;"
											+ result.obj[i].title 
											+ "&nbsp;</br>&nbsp;&nbsp;"
											+ result.obj[i].substance
											+ "&nbsp;</blockquote></p><small><p style='color:#123456;'>"				
											+ "&nbsp;来自&nbsp;"
											+ result.obj[i].schoolName
											+ "&nbsp;"
											+ sub_time
											+ "</small></main></a>";
								


								$wrapper.append(sub_panel+"");
							}
						} else {
							$("#doc-scrollspy-wrapper")
									.append(
											"<div class='am-alert'> 暂时没有帮助信息哦 ！ </div>");
						}

					},
					error : function(request, error) {
						$("#doc-scrollspy-wrapper").append(
								"<div class='am-alert'> 暂时没有帮助信息哦 ！ </div>");
					}

				});
	}

	//格式化日期
	function formatDate(strTime) {
		var date = new Date(strTime);
		return date.getFullYear() + "-" + (date.getMonth() + 1) + "-"
				+ date.getDate() + " " + date.getHours() + ":"
				+ date.getMinutes() + ":" + date.getSeconds();
	}

	//返回上一页	
	function back() {
		history.back()
	}
</script>

</head>

<body>
<header data-am-widget="header"
          class="am-header am-header-default joan-head">
      <div class="am-header-left am-header-nav">
          <a href="/mobile/goMain" target="_self" class="">
                返回
          </a>
      </div>

      <h2 class="am-header-title">
                 校园新鲜事
      </h2>
   
 

  </header>

  <div  id="campus" data-am-widget="list_news" class="am-list-news am-list-news-default" >
 

 
    
     <!--缩略图在标题左边-->
     
     
   
   
  </div>



     <!-- 分页 -->
	<div id="top_count_num"></div>

	<div id="doc-scrollspy-wrapper" data-am-observe></div>

	<!-- 分页 -->
	<div id="count_num"></div>


</body>

</html>
